﻿namespace com.oakwoodsys.ConsultantCare
{
    using System.Linq;

    using com.oakwoodsys.ConsultantCareDao;
    using com.oakwoodsys.SharePoint;

    using Microsoft.SharePoint;

    using ReferenceObject = com.oakwoodsys.ConsultantCareDao.ConsultantActivityID;

    public class ConsultantActivityID_Definition_WebLevel : CustomBaseDefinition
    {
        #region Constructors

        public ConsultantActivityID_Definition_WebLevel( SPFeatureReceiverProperties properties )
            : base(properties)
        {
        }

        ~ConsultantActivityID_Definition_WebLevel( )
        {
            Dispose( false );
        }

        #endregion Constructors

        #region Methods

        public override void Create( )
        {
            base.Create( );
            CreateList( getListDefn( ) );
        }

        public override void Delete( )
        {
            base.Delete( );
            bool force = false;
            if ( ListIsNullOrEmpty( ConsultantCareDao.ConsultantDao.ListName ) )
                force = true;
            DeleteList( getListDefn( ), force );
        }

        ListDefn getListDefn( )
        {
            return new ListDefn
            {
                RootFolderName = ConsultantActivityIDDao.ListName,
                Title = "Consultant and related Activities",
                Description = "Contains Consultant and related Activities",
                Hidden = true,
                ContentTypes = new string[ ]
                {
                    Item.GetContentTypeName<ReferenceObject>( )
                }.ToList( )
            };
        }

        #endregion Methods
    }
}